package main

import (
	"os"
	"fmt"
	"strconv"
	"encoding/csv"
)

type Product struct {
	name string
	price float64
	quantity int
}

func main() {
	f,_:=os.Open("products.txt")
	defer f.Close()

	products:=[]*Product{}

	rd:=csv.NewReader(f)
	for {
		record,err:=rd.Read()
		fmt.Println(err)
		if err!= nil { break }

		name:=record[0]

		price,perr:=strconv.ParseFloat(record[1],64)
		if perr!=nil {break}

		quantity,qerr:=strconv.Atoi(record[2])
		if qerr!=nil { break }

		products=append(products, &Product{name,price,quantity})
	}

	fmt.Println(products)
}
